<template>
  <div class="NavBarWrap">
    <ul>
      <li
        :class="{ active: '/' + item.path == $route.path }"
        v-for="item in list"
        :key="item.path"
        @click="toPage(item.path)"
      >
        <img
          :src="
            '/' + item.path == $route.path ? item.meta.iconSel : item.meta.icon
          "
          alt=""
        />
        {{ item.meta.title }}
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  mounted() {
    // console.log(14, this.$router);
  },
  computed: {
    list() {
      let routes = this.$router.options.routes[0].children;
      routes = routes.filter((item) => !item.meta.hidden);
      return routes;
    },
  },
  methods: {
    toPage(path) {
      if (path == this.$route.path) {
        return;
      }
      this.$router.push(path);
    },
  },
};
</script>

<style lang='scss' scoped>
.NavBarWrap {
  width: 200px;
  background-color: rgb(57, 61, 73);
  height: calc(100vh - 80px);
  text-align: center;
  ul {
    margin-top: 20px;
  }
  li {
    color: white;
    margin-top: 6px;
    cursor: pointer;
    img{
      width: 14px;
    }
  }
  li:hover {
    color: #e5790f;
  }
  .active{
      color :#e5790f;
  }
}
</style>